package com.xyongfeng.foodManagement.domain;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.xyongfeng.foodManagement.domain.group.AddGroup;
import com.xyongfeng.foodManagement.domain.group.NormalGroup;
import lombok.Data;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.util.Date;

/**
 * @TableName food_out_info
 */
@TableName(value = "t_food_out_info")
@Data
public class FoodOutInfo implements Serializable, Cloneable {
    /**
     * 出库单号
     */
    @TableId(type = IdType.ASSIGN_ID)
    private String outId;

    /**
     * 食品编号
     */
    private Integer outFoodId;

    /**
     * 出库数量
     */
    @Min(value = 0, message = "出库数量不能为负数", groups = {NormalGroup.class})
    @NotNull(message = "出库数量不能为空", groups = {AddGroup.class})
    private Integer outNum;


    /**
     * 出库时间
     */
    private String outTime;

    /**
     * 管理员工号
     */
    private Integer outAdminId;

    /**
     * 管理员工信息
     */
    @TableField(exist = false)
    private AdminInfo adminInfo;

    /**
     * 食品信息
     */
    @TableField(exist = false)
    private FoodInfo foodInfo;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        FoodOutInfo other = (FoodOutInfo) that;
        return (this.getOutId() == null ? other.getOutId() == null : this.getOutId().equals(other.getOutId()))
                && (this.getOutFoodId() == null ? other.getOutFoodId() == null : this.getOutFoodId().equals(other.getOutFoodId()))
                && (this.getOutNum() == null ? other.getOutNum() == null : this.getOutNum().equals(other.getOutNum()))
                && (this.getOutTime() == null ? other.getOutTime() == null : this.getOutTime().equals(other.getOutTime()))
                && (this.getOutAdminId() == null ? other.getOutAdminId() == null : this.getOutAdminId().equals(other.getOutAdminId()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getOutId() == null) ? 0 : getOutId().hashCode());
        result = prime * result + ((getOutFoodId() == null) ? 0 : getOutFoodId().hashCode());
        result = prime * result + ((getOutNum() == null) ? 0 : getOutNum().hashCode());
        result = prime * result + ((getOutTime() == null) ? 0 : getOutTime().hashCode());
        result = prime * result + ((getOutAdminId() == null) ? 0 : getOutAdminId().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", outId=").append(outId);
        sb.append(", outFoodId=").append(outFoodId);
        sb.append(", outNum=").append(outNum);
        sb.append(", outTime=").append(outTime);
        sb.append(", outAdminId=").append(outAdminId);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }

    @Override
    public FoodOutInfo clone() {
        FoodOutInfo foodOutInfo = new FoodOutInfo();

        BeanUtil.copyProperties(this, foodOutInfo);
        return foodOutInfo;
    }
}